 
function getGraphics(){
    try{
        //var _loading = document.getElementById(loading);
        //if(_loading) _loading.style.visibility="visible";
        //this.setTimeout(getGraphicsImp(loading), 1000);
        if(document.getElementById("chartdiv"))this.setTimeout(getGraphicsImp(), 1000);
    }catch(ex){}
}

function getGraphicsImp(){
    var idScoreCard = document.getElementById("idScoreCard").getAttribute("value");
    var startDate = document.getElementById("startDate").getAttribute("value");
    var endDate = document.getElementById("endDate").getAttribute("value");
    var path="ajaxDashboardPointer.do?scoreCard="+idScoreCard + "&startDate="+startDate+"&endDate=" + endDate;
    //alert("El path es: " + path);
    var ajax = new accesoAJAX.CargadorDeDatos("POST",path,
        function(data){
            //alert(data);
            var _charContainer = document.getElementById("chartdiv").innerHTML = "";
            var chart;
            var legend;

            var XMLresponse = buildXMLFromString(data);
            var elems = XMLresponse.getElementsByTagName("register");
            var scoresInfo = XMLresponse.getElementsByTagName("scoreInfo");
            if(elems){

                var datos = new Array();
                        
                        

                for(var i=0;i<elems.length;i++){
                    // alert(elems[i]+","+i);
                    var register = elems[i];
                    var date = register.getAttribute("date");
                    var datas = register.childNodes;
                    var real,goal;
                    for(var j=0;j<datas.length;j++){
                        if(datas[j].getAttribute){
                            var type = (datas[j].getAttribute("type"));
                            if(type == "REAL")real = datas[j].getAttribute("value");
                            if(type == "GOAL" || type == "CUSTOM")goal = datas[j].getAttribute("value");
                        }

                    }
                    //alert("Date: " + date + ". Real: " + real +". Goal: " + goal + "." );

                    datos[i] = {
                        period:date,
                        real:real,
                        goal:goal
                    };
                    real= undefined;
                    goal= undefined;
                }


                        
                        
                var scoreInfo = scoresInfo[0];
                var unit = scoreInfo.getAttribute("unit");
			
                chart = new AmCharts.AmSerialChart();
                chart.dataProvider = datos;
                chart.categoryField = "period";
                chart.startDuration = 1;
                chart.marginTop = 25;
                chart.marginLeft = 85;
                chart.rotate = false;


                var graph1 = new AmCharts.AmGraph();
                graph1.title = "Real";
                graph1.valueField = "real";
                graph1.type = "column";
                graph1.lineAlpha = 0;
                graph1.fillColors = "#28669C";
                graph1.balloonText="[[value]]"+"("+unit+")";
                graph1.fillAlphas = 1;
                chart.addGraph(graph1);

                var graph2 = new AmCharts.AmGraph();
                graph2.title = "Meta";
                graph2.valueField = "goal";
                graph2.type = "line";
                graph2.lineThickness = 2;
                graph2.lineColor = "#D8E017";
                graph2.balloonText="[[value]]"+"("+unit+")";
                graph2.bullet = "round";
                graph2.fillAlphas = 0;
                chart.addGraph(graph2);

                var catAxis = chart.categoryAxis;
                catAxis.gridPosition = "start";
                catAxis.dashLength = 5;

                var valAxis = new AmCharts.ValueAxis();
                valAxis.dashLength = 5;
                chart.addValueAxis(valAxis);

                var valAxis2 = new AmCharts.ValueAxis();
                valAxis2.position = "top";
                chart.addValueAxis(valAxis2);

                var legend = new AmCharts.AmLegend();
                legend.align = "center";
                chart.addLegend(legend);

                chart.write("chartdiv");
            }
        // document.getElementById(loading).style.visibility="hidden";
        });
}

        